<template>
    <transition name="fade">
        <div class="right-main-warp" v-show="visible">
            <div class="author-inner">
                <div class="icon-warp">
                    <Icon @iconHandle="iconHandle"></Icon>
                </div>
                <div class="author-avatar">
                    <span class="avatar-warp">
                        <img src="https://image.huos77.cn/img/huos.jpg" />
                    </span>
                    <div class="introduce-container">
                        <p>小7保安</p>
                        <p class="introduce-text">一个热爱篮球的boys</p>
                    </div>
                </div>
                <div class="author-maincontent">
                    <div>
                        <p>{{ articleNum }}</p>
                        <span>文章</span>
                    </div>
                    <div>
                        <p>{{ tagNum }}</p>
                        <span>标签</span>
                    </div>
                    <div>
                        <p>{{ diaryNum }}</p>

                        <span>日记</span>
                    </div>
                </div>
                <div class="otherAPP">
                    <div>
                        <span class="links-of-author-item">
                            <a
                                href="https://space.bilibili.com/475086554"
                                title="bilibili"
                                target="blank"
                            ></a>
                        </span>
                    </div>
                    <div>
                        <span>
                            <a
                                href="https://www.zhihu.com/people/one-76-73-78"
                                title="zhihu"
                                target="blank"
                                class="links-of-author-item-zhihu"
                            >
                            </a>
                        </span>
                    </div>
                    <div>
                        <span>
                            <a
                                href="https://gitee.com/echoc"
                                title="github"
                                target="blank"
                                class="links-of-author-item-github"
                            ></a>
                        </span>
                    </div>
                    <div>
                        <span>
                            <a
                                href="mailto: whuos200902@outlook.com"
                                title="E-Mail"
                                class="links-of-author-item-Email"
                            ></a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </transition>
</template>

<script>
export default {
    data() {
        return {
            clickflag: false,
        }
    },
    computed: {
        visible() {
            return this.$store.getters.auth
        },
        articleNum() {
            return this.$store.getters.articleNum
        },
        tagNum() {
            return this.$store.getters.tagNum
        },
        diaryNum() {
            return this.$store.getters.diaryNum
        },
    },
    methods: {
        async initData() {
            let tagNum = this.$store.getters.tagNum
            let diaryNum = this.$store.getters.diaryNum
            if (tagNum == 0) {
                await this.$store.dispatch('tag/getTag')
            }
            if (diaryNum == 0) {
                await this.$store.dispatch('diary/agetDiary')
            }
            //     this.delay(this.$store.getters.articleNum, 'articleNum')
            //     this.delay(this.$store.getters.diaryNum, 'diaryNum')
            //     this.delay(this.$store.getters.tagNum, 'tagNum')
        },
        // delay(num, key) {
        //     switch (key) {
        //         case 'diaryNum':
        //             for (let i = 0; i < num; i++) {
        //                 setTimeout(() => {
        //                     this.diaryNum++
        //                 }, i * 50)
        //             }
        //             break
        //         case 'articleNum':
        //             for (let i = 0; i < num; i++) {
        //                 setTimeout(() => {
        //                     this.articleNum++
        //                 }, i * 50)
        //             }
        //             break
        //         case 'tagNum':
        //             for (let i = 0; i < num; i++) {
        //                 setTimeout(() => {
        //                     this.tagNum++
        //                 }, i * 50)
        //             }
        //     }
        // },
        iconHandle() {
            this.$store.commit('app/TOGGLE_AUTH')
        },
    },
    created() {
        this.initData()
    },
}
</script>
<style lang="less" scoped>
.author-inner {
    text-align: center;
}

.icon-warp {
    position: absolute;
    right: 10px;
    top: 10px;
}

@keyframes author-card-fade {
    0% {
        transform: translateY(-10px);
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@keyframes author-line-fade {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

.author-avatar {
    margin-top: 50px;
    padding: 10px;
    .avatar-warp {
        img {
            border: 3px solid rgba(49, 49, 49, 0.2);
            cursor: pointer;
            display: inline-block;
            margin-bottom: 10px;
            padding: 1px;
            width: 90px;
            height: 90px;
            border-radius: 100%;
            overflow: hidden;
            transition: all 0.4s;
            animation: author-card-fade 0.6s ease-out 1;
            &:hover {
                transform: scale(1.3) rotate(360deg) translateY(-10%);
            }
        }
    }

    .introduce-container {
        opacity: 0;
        animation: author-card-fade 0.6s ease-out 0.4s 1 forwards;

        .introduce-text {
            font-size: 12px;
            color: #999;
            margin-top: 10px;
        }
    }
}

.author-avatar::before {
    content: '';
    position: absolute;
    left: 88px;
    bottom: 165px;
    width: 160px;
    height: 1px;
    background-color: var(--default);
    opacity: 0;
    animation: author-line-fade 2s ease-out 1 forwards;
}
.author-maincontent {
    opacity: 0;
    display: flex;
    justify-content: space-around;
    animation: author-card-fade 0.6s ease-out 0.8s 1 forwards;

    div {
        width: 100px;
        p {
            padding-top: 35px;
            font-weight: 700;
            font-size: 17px;
            color: #00a1d6;
        }
        span {
            display: inline-block;
            padding-top: 16px;
        }
    }
}
.otherAPP {
    display: flex;
    justify-content: space-around;
    padding: 20px 0;
    div {
        background-color: #e5e5e5;
        width: 40px;
        height: 40px;
        border-radius: 999px;
        line-height: 40px;
        a::before {
            font-family: 'iconfont';
            content: '\e62a';
            font-size: 30px;
            color: #1296db;
            text-align: center;
        }
        .links-of-author-item-zhihu::before {
            content: '\ea8b';
        }
        .links-of-author-item-github::before {
            content: '\e677';
            color: black;
        }
        .links-of-author-item-Email::before {
            content: '\e605';
            color: black;
        }
    }
}
</style>
